﻿using Loogn.OrmLite;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Web;

namespace Stardust.ConfigCenterWeb.Code.Repositories.Impl
{
    public class DB
    {
        static DB()
        {
            OrmLite.RegisterProvider(OrmLiteProviderType.MySql, MySqlOrmLiteProvider.Instance);
        }
        public static MySqlConnection Open()
        {
            return new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["db"].ConnectionString);
        }
    }

    class MySqlOrmLiteProvider : IOrmLiteProvider
    {
        private MySqlOrmLiteProvider() { }

        public static MySqlOrmLiteProvider Instance = new MySqlOrmLiteProvider();
        public DbParameter CreateParameter(string name, object value)
        {
            return new MySqlParameter(name, value);
        }
    }
}